<template>
  <div>
    <!-- 轮播图 -->
    <van-swipe class="my-swipe" :autoplay="3000" indicator-color="white">
      <van-swipe-item style="height: 200px" v-for="item in swipe" :key="item.id">
        <a :href="item.url">
        <img :src="item.img" alt="静静保洁有限公司" class="swipeImg">
        </a>
      </van-swipe-item>
    </van-swipe>
    <!-- 导航图标 -->
    <div class="home">
      <router-link to="newslist"> <img src="./homeimg/menu1.png" alt="" class="homeimg"> <span>新闻资讯</span></router-link>
      <router-link to="photo/list"> <img src="./homeimg/menu2.png" alt="" class="homeimg"> <span>图片分享</span></router-link>
      <router-link to="goods/list"> <img src="./homeimg/menu3.png" alt="" class="homeimg"> <span>商品购买</span></router-link>
      <router-link to="newslist"> <img src="./homeimg/menu4.png" alt="" class="homeimg"> <span>视频专区</span></router-link>
      <router-link to="newslist"> <img src="./homeimg/menu5.png" alt="" class="homeimg"> <span>留言反馈</span></router-link>
      <router-link to="contact"> <img src="./homeimg/menu6.png" alt="" class="homeimg"> <span>联系我们</span></router-link>
    </div>
  </div>
</template>

<script>
export default {
  data () {
    return {
      swipe: []
    }
  },

  created () {
    this.getSwiper()
  },

  methods: {
    async getSwiper () {
      const res = await this.$axios.get('api/getlunbo')
      if (res.status !== 200) return
      this.swipe = res.data.message
    }
  }
}
</script>

<style scoped lang='less'>
// 轮播图
.my-swipe .van-swipe-item {
  color: #fff;
  font-size: 20px;
  line-height: 200px;
  text-align: center;
  background-color: #39a9ed;
}

.swipeImg {
  height: 100%;
  width: 100%;
}

.homeimg {
  width: 60px;
  height: 60px;
}

// 导航图标
.home {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-around;
  > a {
    display: block;
    padding: 15px 5px;
    width: 100px;
    height: 100px;
    text-align: center;
    > span {
      display: inline-block;
      color: #333;
      font-size: 14px;
      margin-top: 5px;
    }
  }
}
</style>
